<html lang="en"><head>
  <meta charset="utf-8">
  <title>{:config('APP_TITLE_SNAME')}</title>
  <meta name="description" content="particles.js is a lightweight JavaScript library for creating particles.">
  <meta name="author" content="Vincent Garreau">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <link rel="stylesheet" media="screen" href="/static/index/css/style.css">
  <link rel="stylesheet" type="text/css" href="/static/index/css/reset.css">
  <link rel="stylesheet" type="text/css" href="/static/index/need/layer.css">
</head>
<body>

<div id="particles-js">
		<div class="login">
			<div class="login-top">
				{:config('APP_SNAME')}登录
			</div>
			<div class="login-center clearfix">
				<div class="login-center-img"><img src="/static/index/img/name.png"></div>
				<div class="login-center-input">
					<input type="text" name="user" id="user" value="" placeholder="请输入您的用户名" onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的用户名'">
					<div class="login-center-input-text">用户名</div>
				</div>
			</div>
			<div class="login-center clearfix">
				<div class="login-center-img"><img src="/static/index/img/password.png"></div>
				<div class="login-center-input">
					<input type="password" name="pwd" id="pwd" value="" placeholder="请输入您的密码" onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的密码'">
					<div class="login-center-input-text">密码</div>
				</div>
			</div>
			<div class="login-center clearfix">
		        <div class="login-center-img"><img src="/static/index/img/yzm.png"></div>
		        <div class="login-center-input">
		          <input type="text" name="captcha" id="captcha" value="" style="width:50%;">
		          <img src="{:captcha_src()}" id="img" name="captcha" onclick="refreshVerify()" style="width:40%">
		          <div class="login-center-input-text" >验证码</div>
		        </div>
		      </div>
			<div class="login-button" id="btn">
				登陆
			</div>
		</div>
		<div class="sk-rotating-plane"></div>
<canvas class="particles-js-canvas-el" width="375" height="812" style="width: 100%; height: 100%;"></canvas></div>

<!-- scripts -->
<script src="/static/index/js/particles.min.js"></script>
<script src="/static/index/js/app.js"></script>
<script src="/static/index/layer.js"></script>
<script src="/static/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
    if (self.frameElement && self.frameElement.tagName == "IFRAME") {
    　　parent.location.reload();
    }
})
var captchaid = '';
function refreshVerify() {
    captchaid = Math.random();
    $('#img').attr("src", "{:captcha_src()}?id="+captchaid);
    $("#btn").removeAttr("disabled");
}
document.onkeydown = function (event) {
    e = event ? event : (window.event ? window.event : null);
    if(e.keyCode == 13){
        $("#btn").click();
        $("#btn").attr('disabled',true);
    }
}

$('#btn').click(function () {
    var user = $('#user').val();
	var pwd = $('#pwd').val();
	var captcha = $('#captcha').val();
	if(user == ''){
		msg('请输入您的用户名');
		return false;
	}
	if(pwd == ''){
		msg('请输入您的密码');
		return false;
	}
	if(captcha == ''){
        msg('请输入验证码');
        return false;
    }


    $.ajax({
        url: '{:url("Login/doLogin")}',
        type: 'post',
        data: {
            'user' : user,
            'pwd' : pwd,
            'captcha' : captcha,
            'captchaid' : captchaid
        },
        dataType : 'json',
        error:function () {
            msg('网络连接错误');
            $('#img').click();
        },
        success:function(data){
            // console.log(data);
            if(data.errorCode == 0){
                location.href = data.url;
            }else{
                msg(data.msg);
                $('#img').click();
            }
        }
    });
});
function msg(msg)
{
	layer.open({
		content: msg
		,skin: 'msg'
		,time: 2 //2秒后自动关闭
	});
}
</script>

</body></html>